<?php


namespace app\index\controller;
use app\cms\model\Slider as SliderModel;

use app\admin\model\Config as ConfigModel;
/**
 * 前台首页控制器
 * @package app\index\controller
 */
class Index extends Home
{
    public function index()
    {
        // 默认跳转模块
        if (config('home_default_module') != 'index') {
            $this->redirect(config('home_default_module'). '/index/index');
        }
        return '<style type="text/css">*{ padding: 0; margin: 0; } .think_default_text{ padding: 4px 48px;} a{color:#2E5CD5;cursor: pointer;text-decoration: none} a:hover{text-decoration:underline; } body{ background: #fff; font-family: "Century Gothic","Microsoft yahei"; color: #333;font-size:18px} h1{ font-size: 100px; font-weight: normal; margin-bottom: 12px; } p{ line-height: 1.6em; font-size: 42px }</style><div style="padding: 24px 48px;"> <h1>:)</h1><p> '.config("gootop.product_name").' '.config("gootop.product_version").'<br/><span style="font-size:30px">极速 · 极简 · 极致</span></p></div>';
    }

    /**
     *
     */
    public function api(){
        $data_list = SliderModel::
            join('gt_admin_attachment photo','gt_cms_slider.cover = photo.id','LEFT')
            ->where(['gt_cms_slider.status'=>1])
            ->order('gt_cms_slider.sort desc')
            ->field('gt_cms_slider.id,gt_cms_slider.title,gt_cms_slider.cover,gt_cms_slider.url,photo.path,gt_cms_slider.sort')
            ->select();
        $config = ConfigModel::where('id > 39')->column('name,value');
        $data = [];
        $list =[];
        if($data_list){
//            $list = $data_list;
            foreach ($data_list as $item) {
                $list[] = $item->toArray();
            }
        }
        $data['config'] = $config;
        $data['list'] = $list;
        echo json_encode($data);exit;
        echo '<pre>';
        print_r($data);exit;
    }
}
